<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>修改题库</title>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>
<br>
<br>
<br>
<br>
<br>
<center>
    <br>
    题库名称:<input id="name" type="text" value="${Repo.name}" /><br>
    <br>
    创建者id:<input id="userId" type="number" value="${Repo.userId}" /><br>
    <br>
    创建时间:<input id="createTime" type="datetime-local"value="${Repo.createTime}" /><br>
    <br>
    <button onclick="update();">保存</button>
</center>
</body>
<script language="JavaScript" type="application/javascript">
    function update(){
        var createTime = $("#createTime").val();
        var userId = $("#userId").val();
        var name = $("#name").val();
        // 判断
        $.ajax({
            type: "post",
            url: "/repocontroller/update",
            data: {
                "id":${Repo.id},
                "createTime":createTime,
                "userId":userId,
                "name":name
            },
            success: function (data){
                var code = JSON.parse(data);
                if(code.code == "1"){
                    alert("修改成功")
                    location.href = "/repocontroller";
                } else {
                    alert("修改数据失败。");
                }
            }
        })
    }
</script>
</html>
